#include "common.h"
#include "Identifier.h"
#include "Special.h"

TokenExtractor Identifier::extractor = TokenExtractor([](char in){
	return isalpha(in) || in == '_';
}, [](char first, ifstream& rest)->Token*{
	string builder;

	do
	{
		builder += first;
		rest.read(&first, 1);
	}
	while(isalnum(first) || first == '_');

	rest.unget();

	if(Special::isSpecial(builder)) return new Special(builder);
	return new Identifier(builder);
});

string Identifier::print() const
{
	return getTokenString();
}

string Identifier::printType() const
{
	return "<IDENTIFIER>";
}
